﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Vds2465Telegrams
{
    [TestClass]
    public class Telegram_Returning_Test
    {
        [TestMethod]
        [Owner("Frank Eppink")]
        public void Test01_Equals()
        {
            Telegram_Returning telegramReturning = new Telegram_Returning(eDirection.ATE_to_RCT, 0x57, eTelegramFunction_Returning.FC_ERROR, true, false);
            {
                // completely different type - NOT equal
                object dummyObject = new object();
                Assert.IsFalse(telegramReturning.Equals(dummyObject));
            }

            {
                // equal
                Telegram_Returning telegramReturning2Compare = new Telegram_Returning(telegramReturning.Direction, telegramReturning.Address,
							telegramReturning.TelegramFunction, telegramReturning.AccessDemandFlag, telegramReturning.DataFlowControlStopFlag);
                Assert.IsTrue(telegramReturning.Equals(telegramReturning2Compare));
            }

            {
                // direction differs - NOT equal
				eDirection direction;
				if (telegramReturning.Direction == eDirection.ATE_to_RCT)
				{
					direction = eDirection.RCT_to_ACE;
				}
				else
				{
					direction = eDirection.ATE_to_RCT;
				}
				Telegram_Returning telegramReturning2Compare = new Telegram_Returning(direction, telegramReturning.Address,
							telegramReturning.TelegramFunction, telegramReturning.AccessDemandFlag, telegramReturning.DataFlowControlStopFlag);
                

                Assert.IsFalse(telegramReturning.Equals(telegramReturning2Compare));
            }

            {
                // address differs - NOT equal
				Telegram_Returning telegramReturning2Compare = new Telegram_Returning(telegramReturning.Direction, (byte)(telegramReturning.Address - 1),
							telegramReturning.TelegramFunction, telegramReturning.AccessDemandFlag, telegramReturning.DataFlowControlStopFlag);
                Assert.IsFalse(telegramReturning.Equals(telegramReturning2Compare));
            }

            {
                // function differs - NOT equal
				eTelegramFunction_Returning telegramFunctionReturning;
				if (telegramReturning.TelegramFunction == eTelegramFunction_Returning.RESPOND_NAK)
				{
					telegramFunctionReturning = eTelegramFunction_Returning.RESPOND_STATUS;
				}
				else
				{
					telegramFunctionReturning = eTelegramFunction_Returning.RESPOND_NAK;
				}
				Telegram_Returning telegramReturning2Compare = new Telegram_Returning(telegramReturning.Direction, telegramReturning.Address,
							telegramFunctionReturning, telegramReturning.AccessDemandFlag, telegramReturning.DataFlowControlStopFlag);
                Assert.IsFalse(telegramReturning.Equals(telegramReturning2Compare));
            }

            {
                // AccessDemandFlag differs - NOT equal
				Telegram_Returning telegramReturning2Compare = new Telegram_Returning(telegramReturning.Direction, telegramReturning.Address,
							telegramReturning.TelegramFunction, !telegramReturning.AccessDemandFlag, telegramReturning.DataFlowControlStopFlag);
                Assert.IsFalse(telegramReturning.Equals(telegramReturning2Compare));
            }

            {
                // DataFlowControlStopFlag differs - NOT equal
				Telegram_Returning telegramReturning2Compare = new Telegram_Returning(telegramReturning.Direction, telegramReturning.Address,
							telegramReturning.TelegramFunction, telegramReturning.AccessDemandFlag, !telegramReturning.DataFlowControlStopFlag);
                Assert.IsFalse(telegramReturning.Equals(telegramReturning2Compare));
            }
        }

        [TestMethod]
        [Owner("Frank Eppink")]
        public void Test02_GetHashCode()
        {
            Telegram_Returning telegramReturning = new Telegram_Returning(eDirection.ATE_to_RCT, 0x57, eTelegramFunction_Returning.FC_ERROR, true, false);
            int hashCode01 = telegramReturning.GetHashCode();            
        }

        [TestMethod]
        [Owner("Frank Eppink")]
        public void Test03_ToString()
        {
			Telegram_Returning telegramReturning = new Telegram_Returning(eDirection.ATE_to_RCT, 0x57, eTelegramFunction_Returning.FC_ERROR, true, false);
			string string01 = telegramReturning.ToString();
			Assert.IsNotNull(string01);            
        }
    }
}
